package com.reggie;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
//管理员端: http://localhost:8080/backend/page/login/login.html
//用户端:  http://localhost:8080/front/page/login.html

@Slf4j
@SpringBootApplication
//添加了这个注解才可以自定义Filter拦截器
@ServletComponentScan
@MapperScan({"com.reggie.employee.dao","com.reggie.category.dao","com.reggie.dish.dao","com.reggie.setmeal.dao","com.reggie.user.dao"
        , "com.reggie.shoppingcart.dao", "com.reggie.addressBook.dao","com.reggie.order.dao"})
@EnableTransactionManagement
//这个注解可以开启Redis数据库缓存的注解支持，要不然就要像Dish包下我自己手写Redis操作一样
@EnableCaching
public class ReggieApplication {
    public static void main(String[] args) {
        SpringApplication.run(ReggieApplication.class,args);
        log.info("项目启动成功...");
    }

    /**
     * MyBatisPlus的分页插件，直接上官网粘贴就行
     *
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
